home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 1146 / 1146.xpi / chrome / screengrab.jar / content / Capture.js < prev    next >
Text File  |  2009-03-09  |  1KB  |  36 lines

  1.  
  2. screengrab.CaptureViewPort = function(browser, dimensions, onCaptured) {
  3.     if (sg.prefs.javaEnabled()) {
  4.         var htmlDoc = browser.getDocument();
  5.         var canvas = browser.getFilledCanvas(dimensions);
  6.         var embeddedCapture = new screengrab.EmbeddedCapture(htmlDoc, dimensions, canvas.getContext("2d"));
  7.         embeddedCapture.capture(function() {
  8.             onCaptured(canvas);
  9.         }, browser);
  10.     } else {
  11.         var htmlDoc = browser.getDocument();
  12.         htmlDoc.setAllFlashOpaque();
  13.         var canvas = browser.getFilledCanvas(dimensions);
  14.         htmlDoc.undo();
  15.         onCaptured(canvas);
  16.     }
  17. }
  18.  
  19. screengrab.CaptureWindow = function(browser, dimensions, onCaptured) {
  20.     window.setTimeout(function() {
  21.         var dataUrl = screengrab.Java.capture(dimensions);
  22.         var canvas = browser.getCanvas();
  23.         var context = browser.prepareCanvas(canvas, dimensions);
  24.         var img = new Image();
  25.         img.onload = function() {
  26.             try {
  27.                 context.drawImage(img, 0, 0);
  28.                 context.restore();
  29.                 onCaptured(canvas);
  30.             } catch (error) {
  31.                 sg.error(error);
  32.             }
  33.         }
  34.         img.src = dataUrl;
  35.     }, 100);
  36. }